{% extends "_base.html" %}
{% block script %}
<script language="javascript"> 
    function toggle( id, label ) {
        var link = document.getElementById("link_"+id);
        var toggle = document.getElementById("toggle_"+id);
        var hid = document.getElementById("hidden_"+id);
        if(hid.value=="Deleted") {
            hid.value="Normal";
            toggle.innerHTML = "Delete";
            link.innerHTML=label;
        } else {
            hid.value="Deleted";
            toggle.innerHTML = "Restore";
            link.innerHTML="<del>"+label+"</del>";
        }
    } 
</script>
{% endblock %}

{% block content %}
<b>{{doorplate}}</b>
<ul>
    <form method="post" action="/">
        <input type="hidden" name="doorplate" value='{{doorplate}}'>
        {% if isAdmin and not isRunning %}
        <li>New label: <input type="text" name="newlabel" ></li>
        {% endif %}
        <table>
            {% for l in candidates %}
            <tr>
                <input type="hidden" id='hidden_{{l.ID()}}' name='hidden_{{l.ID()}}' value='Normal'>
                <td><li><a id='link_{{l.ID()}}' href="/cell?ID={{l.ID()}}">{{l.label}}</a></li></td>
                <td> - {{l.description}}</td>
                {% if isRunning %}
                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="checkbox" name='check_{{l.ID()}}' value='Checked' {% if l.ID() in subs %} checked {%endif%}></td>
                {% else %}
                {% if isAdmin %}
                <td><a id='toggle_{{l.ID()}}' class="delbutton" href="javascript:toggle('{{l.ID()}}', '{{l.label}}');">Delete</a></td>
                {% endif %}
                {% endif %}
            </tr>
            {% endfor %}
        </table>
        {% if isRunning %}
        <input type="submit" name="b1" value="(Un)subscribe" >
        {% elif isAdmin %}
        <input type="submit" name="b1" value="Submit" >
        {% endif %}
    </form>
</ul>
{% endblock %}
{% block errmessage %}
<p>{{e}}</p>
{% endblock %}
{% block message %}
<p>{{m}}</p>
{% endblock %}
